emerald_animal_aifandomcom-20200215-history
Tutorials
Here you will find various tutorials related to Emerald. This goes for system setups, implementation of other system (such as UFPS), setting up your NavMesh, and more. If you need any help, or would like to suggest a tutorial, you can contact us via our support email. See our contact section of our website for our contact information. Implementing RFPS with Emerald AI This quick tutorial will get Emerald AI working with RFPS. This will allow users to use RFPS to damage, both ranged and melee, Emerald AI agents as well as have Emerald AI damage the RFPS player. This functionality will also allow users to block incoming attacks from Emerald AI agents. Note: This tutorial requires adding a few lines to a couple RFPS scripts and some basic understanding of minor editing of scripts. Setting up the Emerald AI Agent Step 1) To start off, you will need to set all your Emerald AI agents to the Flesh tag and the NPCs layer Step 2) Set your Emerald System Tag, located under the Tag Options, to Flesh. Make sure you set Player uses Separate Layer to true (Aggressive and Defensive Only). This needs to be done with all Emerald AI agents. Step 3) Set your Emerald Layer, located under the Tag Options, to NPCs. This needs to be done for all Emerald AI agents. Step 4) (Aggressive and Defensive Only) Set your Player Layer, located under the Tag Options, to Player. This needs to be done for all Emerald AI agents. Step 5) Press the Add Tag button and add the tag Player to the Target/Flee Tags list, located at the bottom of the Tag Options. This needs to be done for all Emerald AI agents that interact with the Player. Step 6) Open the Emerald_Animal_AI script, press Ctrl+F to bring up the search tool, and search for the line: currentAnimal.SendMessage(SendMessageForPlayerDamage, attackDamage); Step 7) Once you've found the above line, comment it out like shown below using // This makes it easy to undo the RFPS implementation if needed. //currentAnimal.SendMessage(SendMessageForPlayerDamage, attackDamage); Step 8) Underneath the commented line above, add the following line. This will allow Emerald AI agents to send damage to the RFPS player. This will also allow the Player to block incoming damage. currentAnimal.GetComponent().ApplyDamage((float)attackDamage, this.transform, true); Setting up the RFPS Player with Emerald AI Step 1) Open the WeaponBehavior script, press Ctrl+F to bring up the search tool, and search for the line: case 13://hit object is an NPC Step 2) Once you've found the line, you will see a switch statement. Add the following code to case 13 under the last if statement within case 13: if(hit.collider.gameObject.GetComponent()){ hit.collider.gameObject.GetComponent().Damage((int)damageAmt); hit.collider.gameObject.GetComponent().MakeFlee(FPSPlayerComponent.gameObject); hit.collider.gameObject.GetComponent().MakeAttack(FPSPlayerComponent.gameObject); } Step 3) Open the ArrowObject script, press Ctrl+F to bring up the search tool, and search for the line: case 13://hit object is an NPC Step 5) Once you've found the line, you will see a switch statement. Add the following code to case 13 under the last if statement within case 13: if(hitCol.gameObject.GetComponent()){ hitCol.gameObject.GetComponent().Damage((int)damage + (int)damageAddAmt); hitCol.gameObject.GetComponent().MakeFlee(FPSPlayerComponent.gameObject); hitCol.gameObject.GetComponent().MakeAttack(FPSPlayerComponent.gameObject); Destroy(this.gameObject); //This is optional so that the arrow doesn't stick into the AI } The concludes the tutorial with implementing RFPS and Emerald AI. Test your scene to make sure things are working properly. If things aren't working right, you most likely made a mistake during one of the steps. This has been tested and confirmed to work. If you need further help, you can visit the Emerald AI Forums. Implement UFPS with Emerald AI This quick tutorial will get Emerald AI working with UFPS. This will allow users to use UFPS to damage, both ranged and melee, Emerald AI agents as well as have Emerald AI damage the UFPS player. Note: This tutorial requires adding a few lines to one UFPS scripts and some basic understanding of minor editing of scripts. 'Setting up the Emerald AI Agent' Step 1) To start off, you will need to set all your Emerald AI agents to the Emerald AI tag and the Enemy layer. Note: The layer has nothing to do with whether an AI is an enemy or not. It's used because it's the layer that's included and usable with UFPS. Step 2) Set your Emerald System Tag, located under the Tag Options, to Emerald AI. This needs to be done with all Emerald AI agents. Step 3) Set your Emerald Layer, located under the Tag Options, to Enemy. Make sure you set Player uses Separate Layer to true (Aggressive and Defensive Only). This needs to be done for all Emerald AI agents. Step 4) Set your Player Layer, located under the Tag Options, to LocalPlayer. This needs to be done for all Emerald AI agents. Step 5) Press the Add Tag button and add the tag Player to the Target/Flee Tags list, located at the bottom of the Tag Options. This needs to be done for all Emerald AI agents that interact with the Player. Step 6) Finally, go to your AI's Attack Options and change the Player Damage Function Call to "Damage". Setting up the UFPS Player and Bullets Step 1) Find all the UFPS bullets and select them. Make sure the Damage Method Name is Damage and the Damage Mode is set to Unity Message. Step 2) Open the vp_FXBullet script, press Ctrl+F to open up the search tool, and find the line: m_Transform.position = m_Hit.point; Step 3) Underneath the line above, add the following code: if (m_Hit.collider.gameObject.tag "Emerald AI") { if (m_Hit.collider.gameObject.GetComponent().currentAnimal null) { m_Hit.collider.gameObject.GetComponent().MakeFlee(m_Source.gameObject); m_Hit.collider.gameObject.GetComponent().MakeAttack(m_Source.gameObject); } } Step 4) This last step is needed to help convert UFPS's damage calculations so they work properly with Emerald's. Go to your UFPS Player, find the Vp_Simple HUD, and change the Health Multiplier to 1. Next, find the Vp_FP Player Damage Handler, and change the Max Health to 100. The concludes the tutorial with implementing UFPS and Emerald AI. Test your scene to make sure things are working properly. If things aren't working right, you most likely made a mistake during one of the steps. This has been tested and confirmed to work. If you need further help, you can visit the Emerald AI Forums. Setting up Unity's NavMesh For a great guide on setting up your NavMesh, see Untiy's tutorial here: http://docs.unity3d.com/Manual/nav-BuildingNavMesh.html Creating separate areas for different kinds of animals If you want to create different areas for your animals, such as animals that can go both in water and out, but keep land animals out of that areas, than follow this tutorial. This same thing applies for different kinds of animals and their types, you just need some type of object to mask it. Make sure this object is marked as Static. It can be found in the top right corner of the Inspector of that GameObject. 1) Create new Area and call it lets say Don't walk on Water 2) Set your water object to the area Don't walk on Water '''that you just created 3) Go to your AI's NavMeshAgent, that you don't want walking on/in the water, and '''uncheck Don't walk on Water from the'Area Mask ' 4) Rebake your scene. The AI you don't want walking on the water will have the water area marked as unwalkable and the ones that can walk on/in the water will be able to.